﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using RabbitMQ.Client;

namespace ATPlatforms.RabbitSkin
{
    public class DirectProducer<T> : BaseProducerConsumer<T>
    {

        public DirectProducer()
            : base()
        {
            MyExchangeType = ExchangeType.Direct;
        }

        public void SendMessage(T message, string routingKey)
        {
            IBasicProperties basicProperties = Model.CreateBasicProperties();
            Model.BasicPublish(Exchange, routingKey, false, false, basicProperties, MessageSerializer.SerializeMessage(message));
        }


        public override bool OnStart(string routingKey)
        {
            //no queue needed
            return true;
        }
    }
}
